//
// Decompiled with: Decompiler.NET, Version=1.3.1.18439, Culture=neutral, PublicKeyToken=null, Version: 1.3.1.18439
// Decompilation Started at: 3/15/2009 10:34:26 PM
// Copyright 2003 - 2004, Jungle Creatures, Inc., All Rights Reserved. 
// Written by Jonathan Pierce, Email: support@junglecreatures.com
//

namespace PatientManagement

{
		
		#region Namespace Import Declarations
		
			using System.ComponentModel;
			using System.Data.Common;
			using System.Data;
			using System.Data.SqlClient;
			using System.Drawing;
			using System;
			using System.Resources;
			using System.Windows.Forms;
			
		#endregion
		
	public class frmDoiMatKhau : Form
	
	{
		
		#region Fields
			private Button btChange;
			private Button btExit;
			private Container components;
			private string connStr;
			public int flag;
			private Label label1;
			private Label label2;
			private Label label3;
			private Label label4;
			private Label label5;
			private TextBox tbConfirm;
			private TextBox tbNewPass;
			private TextBox tbOldPass;
			private TextBox tbUserName;
		#endregion
		
		#region Constructors
		
			public frmDoiMatKhau ()
			
			{
				this.components = ((System.ComponentModel.Container) null);
				this.flag = 1;
				this.InitializeComponent ();
				this.connStr = Connection.ConnectionString ();
				return;
			}
			
		#endregion
		
		#region Methods
		
			private void btChange_Click (object sender, EventArgs e)
			
			{
				string theString;
				Class theClass;
				SqlConnection theSqlConnection;
				SqlDataAdapter theSqlDataAdapter;
				DataSet theDataSet;
				string theString2;
				string theString3;
				SqlCommand theSqlCommand;
				Exception theException;
				string[] theStringArray;
				string[] theStringArray2;
				if (this.tbUserName.Text != "")
				{
					goto L_002F;
				}
				DialogResult theDialogResult = MessageBox.Show ("B?n ch?a nh?p T?n Truy Nh?p", "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0323;
				
			L_002F:
				
				{
				}
				if (this.tbOldPass.Text != "")
				{
					goto L_005E;
				}
				DialogResult theDialogResult2 = MessageBox.Show ("B?n ch?a nh?p M?t Kh?u C?", "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0323;
				
			L_005E:
				
				{
				}
				if (this.tbNewPass.Text != "")
				{
					goto L_008D;
				}
				DialogResult theDialogResult3 = MessageBox.Show ("B?n ch?a nh?p M?t Kh?u M?i", "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0323;
				
			L_008D:
				
				{
				}
				if (this.tbConfirm.Text != "")
				{
					goto L_00BC;
				}
				DialogResult theDialogResult4 = MessageBox.Show ("Vui l?ng nh?p l?i M?t Kh?u M?i", "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0323;
				
			L_00BC:
				
				{
				}
				if (this.tbConfirm.Text == this.tbNewPass.Text)
				{
					goto L_00F1;
				}
				DialogResult theDialogResult5 = MessageBox.Show ("M?t Kh?u kh?ng ??i x?ng", "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0323;
				
			L_00F1:
				
				{
				}
				if (this.tbNewPass.Text != this.tbOldPass.Text)
				{
					goto L_0126;
				}
				DialogResult theDialogResult6 = MessageBox.Show ("M?t Kh?u m?i kh?ng th? tr?ng v?i m?t kh?u c?", "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0323;
				
			L_0126:
				
				{
				}
				if (this.tbNewPass.Text.Length >= 6)
				{
					goto L_0151;
				}
				DialogResult theDialogResult7 = MessageBox.Show ("M?t Kh?u ph?i t? 6 - 10 k? t?", "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0323;
				
			L_0151:
				
				{
				}
				theString = this.tbOldPass.Text.ToString ();
				theClass = new Class ();
				theString = theClass.Encrypt (theString);
				theSqlConnection = new SqlConnection (this.connStr);
				theStringArray = new string[5];
				theStringArray[0] = "SELECT * FROM Users WHERE usrName=\'";
				theStringArray[1] = this.tbUserName.Text.Trim ();
				theStringArray[2] = "\' AND usrPassword=\'";
				theStringArray[3] = theString;
				theStringArray[4] = "\'";
				theSqlDataAdapter = new SqlDataAdapter (string.Concat (theStringArray), theSqlConnection);
				theDataSet = new DataSet ();
				int i = theSqlDataAdapter.Fill (theDataSet, "Users");
				if ((theDataSet != null) && ((theDataSet.Tables.Count != 0) && (theDataSet.Tables[0].Rows.Count != 0)))
				{
					goto L_021E;
				}
				
			L_0206:
				
				{
				}
				DialogResult theDialogResult8 = MessageBox.Show ("T?n ??ng Nh?p ho?c M?t Kh?u kh?ng h?p l?!", "L?i Nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0317;
				
			L_021E:
				
				{
				}
				theString2 = this.tbNewPass.Text.ToString ();
				theString2 = theClass.Encrypt (theString2);
				theStringArray2 = new string[5];
				theStringArray2[0] = "UPDATE Users SET usrPassword=\'";
				theStringArray2[1] = theString2;
				theStringArray2[2] = "\' WHERE usrName=\'";
				theStringArray2[3] = this.tbUserName.Text;
				theStringArray2[4] = "\'";
				theString3 = string.Concat (theStringArray2);
				theSqlCommand = new SqlCommand (theString3, theSqlConnection);
				
			L_0285:
				try
				{
					theSqlCommand.Connection.Open ();
					int i2 = theSqlCommand.ExecuteNonQuery ();
					theSqlCommand.Connection.Close ();
					this.tbUserName.Text = "";
					this.tbOldPass.Text = "";
					this.tbNewPass.Text = "";
					this.tbConfirm.Text = "";
					bool theBoolean = this.tbUserName.Focus ();
					DialogResult theDialogResult9 = MessageBox.Show ("M?t kh?u ?? ???c thay ??i!", "??i M?t Kh?u Th?nh C?ng", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				catch (Exception theException2)
				{
					
				L_0306:
					theException = theException2;
					DialogResult theDialogResult10 = MessageBox.Show (theException.Message);
				}
				
			L_0317:
				
				{
				}
				theSqlDataAdapter.Dispose ();
				theSqlConnection.Close ();
				
			L_0323:
				return;
			}
			
			private void btExit_Click (object sender, EventArgs e)
			
			{
				base.Close ();
				return;
			}
			
			protected override void Dispose (bool disposing)
			
			{
				this.flag = 0;
				if (! disposing)
				{
					goto L_001D;
				}
				if (this.components == null)
				{
					goto L_001D;
				}
				this.components.Dispose ();
				
			L_001D:
				
				{
				}
				base.Dispose (disposing);
				return;
			}
			
			private void InitializeComponent ()
			
			{
				ResourceManager theResourceManager;
				Control[] theControlArray;
				theResourceManager = new ResourceManager (typeof (frmDoiMatKhau));
				this.label1 = new Label ();
				this.label2 = new Label ();
				this.label3 = new Label ();
				this.label4 = new Label ();
				this.tbUserName = new TextBox ();
				this.tbOldPass = new TextBox ();
				this.tbNewPass = new TextBox ();
				this.tbConfirm = new TextBox ();
				this.label5 = new Label ();
				this.btChange = new Button ();
				this.btExit = new Button ();
				base.SuspendLayout ();
				this.label1.Location = new Point (24, 64);
				this.label1.Name = "label1";
				this.label1.Size = new System.Drawing.Size (168, 23);
				this.label1.TabIndex = 0;
				this.label1.Text = "T?n ??ng nh?p:";
				this.label2.Location = new Point (24, 88);
				this.label2.Name = "label2";
				this.label2.Size = new System.Drawing.Size (168, 23);
				this.label2.TabIndex = 1;
				this.label2.Text = "M?t kh?u c?:";
				this.label3.Location = new Point (24, 112);
				this.label3.Name = "label3";
				this.label3.Size = new System.Drawing.Size (168, 23);
				this.label3.TabIndex = 2;
				this.label3.Text = "M?t kh?u m?i:";
				this.label4.Location = new Point (24, 136);
				this.label4.Name = "label4";
				this.label4.Size = new System.Drawing.Size (168, 23);
				this.label4.TabIndex = 3;
				this.label4.Text = "Nh?p l?i m?t kh?u m?i:";
				this.tbUserName.BorderStyle = BorderStyle.FixedSingle;
				this.tbUserName.Location = new Point (184, 64);
				this.tbUserName.Name = "tbUserName";
				this.tbUserName.Size = new System.Drawing.Size (168, 23);
				this.tbUserName.TabIndex = 0;
				this.tbUserName.Text = "";
				this.tbOldPass.BorderStyle = BorderStyle.FixedSingle;
				this.tbOldPass.Location = new Point (184, 88);
				this.tbOldPass.Name = "tbOldPass";
				this.tbOldPass.PasswordChar = '\u002A';
				this.tbOldPass.Size = new System.Drawing.Size (168, 23);
				this.tbOldPass.TabIndex = 1;
				this.tbOldPass.Text = "";
				this.tbNewPass.BorderStyle = BorderStyle.FixedSingle;
				this.tbNewPass.Location = new Point (184, 112);
				this.tbNewPass.Name = "tbNewPass";
				this.tbNewPass.PasswordChar = '\u002A';
				this.tbNewPass.Size = new System.Drawing.Size (168, 23);
				this.tbNewPass.TabIndex = 2;
				this.tbNewPass.Text = "";
				this.tbConfirm.BorderStyle = BorderStyle.FixedSingle;
				this.tbConfirm.Location = new Point (184, 136);
				this.tbConfirm.Name = "tbConfirm";
				this.tbConfirm.PasswordChar = '\u002A';
				this.tbConfirm.Size = new System.Drawing.Size (168, 23);
				this.tbConfirm.TabIndex = 3;
				this.tbConfirm.Text = "";
				this.tbConfirm.KeyPress += new KeyPressEventHandler (this.tbConfirm_KeyPress);
				this.label5.Font = new System.Drawing.Font ("Verdana", 12F, FontStyle.Bold, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.label5.ForeColor = Color.MediumBlue;
				this.label5.Location = new Point (128, 16);
				this.label5.Name = "label5";
				this.label5.Size = new System.Drawing.Size (136, 23);
				this.label5.TabIndex = 8;
				this.label5.Text = "??i M?t Kh?u";
				this.btChange.FlatStyle = FlatStyle.Flat;
				this.btChange.Location = new Point (184, 168);
				this.btChange.Name = "btChange";
				this.btChange.Size = new System.Drawing.Size (80, 23);
				this.btChange.TabIndex = 4;
				this.btChange.Text = "Thay ??i";
				this.btChange.Click += new EventHandler (this.btChange_Click);
				this.btExit.FlatStyle = FlatStyle.Flat;
				this.btExit.Location = new Point (277, 168);
				this.btExit.Name = "btExit";
				this.btExit.TabIndex = 5;
				this.btExit.Text = "Tho?t";
				this.btExit.Click += new EventHandler (this.btExit_Click);
				this.AutoScaleBaseSize = new System.Drawing.Size (7, 16);
				base.ClientSize = new System.Drawing.Size (374, 203);
				theControlArray = new Control[11];
				theControlArray[0] = ((Control) this.btExit);
				theControlArray[1] = ((Control) this.btChange);
				theControlArray[2] = ((Control) this.label5);
				theControlArray[3] = ((Control) this.tbConfirm);
				theControlArray[4] = ((Control) this.tbNewPass);
				theControlArray[5] = ((Control) this.tbOldPass);
				theControlArray[6] = ((Control) this.tbUserName);
				theControlArray[7] = ((Control) this.label4);
				theControlArray[8] = ((Control) this.label3);
				theControlArray[9] = ((Control) this.label2);
				theControlArray[10] = ((Control) this.label1);
				base.Controls.AddRange (theControlArray);
				this.Font = new System.Drawing.Font ("Verdana", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
				base.Icon = ((System.Drawing.Icon) theResourceManager.GetObject ("$this.Icon"));
				base.MaximizeBox = false;
				base.MinimizeBox = false;
				base.Name = "frmDoiMatKhau";
				base.StartPosition = FormStartPosition.CenterScreen;
				this.Text = "??i M?t Kh?u";
				base.ResumeLayout (false);
				return;
			}
			
			private void tbConfirm_KeyPress (object sender, KeyPressEventArgs e)
			
			{
				if (e.KeyChar != '\r')
				{
					goto L_0012;
				}
				this.btChange_Click (sender, ((EventArgs) e));
				
			L_0012:
				return;
			}
			
		#endregion
	}
	
}

